package com.jiyun.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jiyun.mapper.SignPerformanceMapper;
import com.jiyun.mapper.juminSexMapper;
import com.jiyun.model.jumin.Jumin;
import com.jiyun.model.statistics.SignPerformance;
import com.jiyun.model.statistics.juminSex;
import com.jiyun.service.SignPerformanceService;
import com.jiyun.service.juminSexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class juminSexServiceImpl extends ServiceImpl<juminSexMapper, Jumin> implements juminSexService {
    @Autowired
    private juminSexMapper juminSexMapper;
    @Override
    public List<juminSex> findSex() {
        List<juminSex> all = new ArrayList<>();
        all=juminSexMapper.findSex();
        return all;
    }

    @Override
    public List<juminSex> showSex() {
        List<juminSex> all = new ArrayList<>();
        all=juminSexMapper.findSex();
        int sum=0;
        for (juminSex juminSex : all) {
            sum=sum+juminSex.getValue();
        }
        for (juminSex juminSex : all) {
            juminSex.setSum(sum);
            Double bili=juminSex.getValue()*100.0/sum;
            double v = Math.round(bili * 100.0) / 100.0;
            juminSex.setBili(v);
        }
        return all;
    }
}
